package com.zb.order.controller;


import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.zb.entity.AccounLoginInfo;
import com.zb.entity.RemarkVo;
import com.zb.result.PageUtil;
import com.zb.result.Result;
import com.zb.service.ZjWorkSuspendService;
import com.zb.utils.TokenUtil;
import com.zb.vo.WorkSuspendChecklVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.regex.Pattern;

/**
 * <p>
 * 工单挂起表 前端控制器
 * </p>
 *
 * @author WEN
 * @since 2024-03-18
 */
@Api(tags = "工单挂起类接口")
@RestController
@RequestMapping("/work/suspend")
public class ZjWorkSuspendController {
    @Resource
    private ZjWorkSuspendService workSuspendService;

    @ApiOperation("获取待审核的挂起工单")
    @GetMapping("/getWaitCheckSupendOrder/{workId}")
    public Result getWaitCheckSupendOrder(@PathVariable @ApiParam(value = "工单ID", required = true) Long workId) {
        return Result.success("获取待审核挂起工单成功").data(PageUtil.row(workSuspendService.getWaitCheckSupendOrder(workId)));
    }

    @ApiOperation("审核挂起的工单")
    @PostMapping("/checkSuspendOrder/{workId}")
    public Result checkSuspendOrder(HttpServletRequest request, @PathVariable @ApiParam(value = "工单ID", required = true) Long workId,
                                    @RequestBody @Valid WorkSuspendChecklVo suspendChecklVo) {
        AccounLoginInfo loginInfo = TokenUtil.getAccountLoginInfo(request);
        workSuspendService.checkSuspendOrder(loginInfo, workId, suspendChecklVo);
        return Result.success("审核挂起的工单成功");
    }

}
